from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from goods.models import SPUSpecification, SPU
from meiduo_admin.serializers.specs import SpecSerserializer, SPUSerializer
from meiduo_admin.utils import PageNum


class  SpecsView(ModelViewSet):
    #商品规格的增删改查
    #指定查询集
    queryset = SPUSpecification.objects.all()
    #指定序列化器
    serializer_class = SpecSerserializer
    #分页器
    pagination_class = PageNum

    # 获取商品spu
    def simple(self,request):
        spus = SPU.objects.all()
        ser =SPUSerializer (spus,many=True)
        return Response(ser.data)


